#include<iostream>
#include<vector> 
using namespace std;
int main(){
	vector<int>a;
	vector<int>::iterator it;
	int b,c;
	while(1){
		cin>>b;
		if(b==0){
			break;
		}
		cout<<b;
		if(b<0){
			cin>>c;
			it=c;
			a.erase(it);
			cout<<b;
		}
		else{
			cin>>c;
			it=b;
			a.insert(it, c);
		}		
	}
	for(it=a.begin();it!=a.end();it++){
		cout<<*it<<" ";
	}
}
